// pages/member/member.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current:1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    getMembers(this);
  },


  switchNav:function(e){
    this.setData({
      current:e.target.id
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    return {
      title: '成都皮肤美容微整',
      path: '/pages/homepage/homepage?id=' + wx.getStorageSync("userid"),
    }
  },
})

function getMembers(that){
  wx.request({
    url: app.globalData.allUrl + "/user/my_user",
    data: {
      user_id: wx.getStorageSync("userid"),
    },
    method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      console.log(res.data);
      var _oneLevel = [];
      var _twoLevel = [];
      for(var i=0;i<res.data.length;i++){
        if (res.data[i].grade=="一级"){
             _oneLevel.push(res.data[i])
        } else if (res.data[i].grade == "二级") {
          _twoLevel.push(res.data[i])
        }
      }
      that.setData({
        oneLevel: _oneLevel,
        twoLevel: _twoLevel,
      })
    }
  })

}